Skip to content

feat(preprod): Add snapshot auto-approval for repeated PR builds#112421

Merged
NicoHinderling merged 9 commits intomasterfrom
snapshots-auto-approval
Apr 8, 2026
Merged

feat(preprod): Add snapshot auto-approval for repeated PR builds#112421
NicoHinderling merged 9 commits intomasterfrom
snapshots-auto-approval

Conversation

@NicoHinderling
Copy link
Copy Markdown
Contributor

@NicoHinderling NicoHinderling commented Apr 7, 2026

Closes EME-976

Adds auto-approval logic for snapshot comparisons. When a snapshot build on a PR is approved and a subsequent build is uploaded for the same PR (e.g. after a rebase), the new build is automatically approved if its "interesting" images (changed, added, removed, errored, renamed) match the previously approved build — same image names, same categories, and same content hashes.

This addresses a pain point where rebasing a PR would pull in new unchanged images from main, causing the snapshot comparison to lose its approval even though the PR's actual visual changes hadn't changed. Users were forced to re-approve identical snapshots after every rebase.

The old Emerge implementation required an exact one-to-one match of ALL images between builds, which broke on rebases. The new approach only compares the non-unchanged subset, so new unchanged images from main don't affect auto-approval. Content hashes are still verified to ensure the PR's actual visual output hasn't changed.

The matching scopes to the same project, app_id, build_configuration, PR number, and repo name to prevent cross-build false matches.

how the UI looks for an auto-approved snapshot
CleanShot 2026-04-07 at 15 45 02@2x

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 7, 2026
@NicoHinderling NicoHinderling force-pushed the snapshots-auto-approval branch from 1f01f62 to 4023b4b Compare April 7, 2026 22:42
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

🚨 Warning: This pull request contains Frontend and Backend changes!

It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently.

Have questions? Please ask in the #discuss-dev-infra channel.

@linear-code
Copy link
Copy Markdown

linear-code bot commented Apr 7, 2026

@NicoHinderling NicoHinderling marked this pull request as ready for review April 7, 2026 23:23
@NicoHinderling NicoHinderling requested a review from a team as a code owner April 7, 2026 23:23
Comment thread src/sentry/preprod/snapshots/tasks.py
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8a77ec7. Configure here.

Comment thread src/sentry/preprod/snapshots/tasks.py Outdated
Comment thread src/sentry/preprod/snapshots/tasks.py Outdated
…comparison

Wrap _try_auto_approve_snapshot in try/except so an unhandled exception
doesn't propagate to the outer BaseException handler, which would
incorrectly mark an already-successful comparison as FAILED.
Comment thread src/sentry/preprod/api/endpoints/preprod_artifact_snapshot.py
Comment thread src/sentry/preprod/snapshots/tasks.py Outdated
Replace raw tuple[str, ...] with a typed ImageFingerprint NamedTuple
for better readability of the name, status, hash, and
previous_image_file_name fields in snapshot auto-approval fingerprints.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment thread src/sentry/preprod/api/endpoints/preprod_artifact_snapshot.py
Comment thread src/sentry/preprod/snapshots/tasks.py
@NicoHinderling NicoHinderling merged commit 23b371a into master Apr 8, 2026
60 checks passed
@NicoHinderling NicoHinderling deleted the snapshots-auto-approval branch April 8, 2026 15:49
george-sentry pushed a commit that referenced this pull request Apr 9, 2026
…2421)

Closes EME-976

Adds auto-approval logic for snapshot comparisons. When a snapshot build
on a PR is approved and a subsequent build is uploaded for the same PR
(e.g. after a rebase), the new build is automatically approved if its
"interesting" images (changed, added, removed, errored, renamed) match
the previously approved build — same image names, same categories, and
same content hashes.

This addresses a pain point where rebasing a PR would pull in new
unchanged images from main, causing the snapshot comparison to lose its
approval even though the PR's actual visual changes hadn't changed.
Users were forced to re-approve identical snapshots after every rebase.

The old Emerge implementation required an exact one-to-one match of ALL
images between builds, which broke on rebases. The new approach only
compares the non-unchanged subset, so new unchanged images from main
don't affect auto-approval. Content hashes are still verified to ensure
the PR's actual visual output hasn't changed.

The matching scopes to the same project, app_id, build_configuration, PR
number, and repo name to prevent cross-build false matches.

how the UI looks for an auto-approved snapshot
<img width="1726" height="1744" alt="CleanShot 2026-04-07 at 15 45
02@2x"
src="https://github.com/user-attachments/assets/e9a01fc0-5a0f-47ef-880d-a4c69f963be2"
/>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants